package com.bwie.home.backstage.controller;

import java.util.Arrays;
import java.util.Map;


import com.bwie.home.backstage.entity.PermEntity;
import com.bwie.home.backstage.service.PermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.R;

/**
 * 
 *
 * @author jrt
 * @email 2014523991@qq.com
 * @date 2021-09-10 21:14:19
 */
@RestController
@RequestMapping("myselfku/perm")
public class PermController {
    @Autowired
    private PermService permService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = permService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{perId}")
    public R info(@PathVariable("perId") Integer perId){
		PermEntity perm = permService.getById(perId);

        return R.ok().put("perm", perm);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PermEntity perm){
		permService.save(perm);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PermEntity perm){
		permService.updateById(perm);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] perIds){
		permService.removeByIds(Arrays.asList(perIds));

        return R.ok();
    }

}
